//
//  LvXingDiInfViewController.m
//  Trip
//
//  Created by dlios on 15-7-15.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "LvXingDiInfViewController.h"
#import "AFNetworkHandler.h"
#import "UIImageView+WebCache.h"

@interface LvXingDiInfViewController ()<UIScrollViewDelegate>

@end

@implementation LvXingDiInfViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    [self headlerData];
    
}

- (void)setScrollView
{
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
//    scrollView.contentSize = CGSizeMake(0, 1500);
    scrollView.delegate = self;
    [self.view addSubview:scrollView];
    UIImageView *images = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 200)];
    [images setImageWithURL:[NSURL URLWithString:[self.souDic objectForKey:@"image_url"]]];
    [scrollView addSubview:images];
    [images release];
    UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(0, 200, self.view.bounds.size.width, 80)];
    label1.text = [self.souDic objectForKey:@"description"];
    label1.numberOfLines = 0;
    CGSize size = [label1 sizeThatFits:CGSizeMake(label1.frame.size.width, MAXFLOAT)];
    label1.frame = CGRectMake(0, 200, self.view.bounds.size.width, size.height);
//    label1.font = [UIFont systemFontOfSize:14];
    [scrollView addSubview:label1];
    [label1 release];
//    UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(0, 260, self.view.bounds.size.width, 500)];
//    label2.text = [self.souDic objectForKey:@"tips_html"];
//    [scrollView addSubview:label2];
//    label2.numberOfLines = 0;
//    [label2 sizeToFit];
//    [label2 release];
    UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 260, self.view.bounds.size.width, 1500)];
    [webView.scrollView setContentInset:UIEdgeInsetsMake(0, 0, 0, 0)];
    [webView loadHTMLString:[self.souDic objectForKey:@"tips_html"] baseURL:nil]; 
    CGSize size1 = [webView sizeThatFits:CGSizeMake(self.view.bounds.size.width, MAXFLOAT)];
    webView.frame = CGRectMake(0, 200 + size.height + 5, self.view.bounds.size.width, size1.height);
    [images addSubview:webView];
    scrollView.contentSize = CGSizeMake(0, 200 + size.height + size1.height);
    UILabel *label3 = [[UILabel alloc] initWithFrame:CGRectMake(0, 165, self.view.bounds.size.width, 20)];
    label3.text = [self.souDic objectForKey:@"name_zh_cn"];
    label3.textColor = [UIColor whiteColor];
    label3.numberOfLines = 0;
    [images addSubview:label3];
    [label3 release];
    UILabel *label4 = [[UILabel alloc] initWithFrame:CGRectMake(0, 185, self.view.bounds.size.width, 15)];
    label4.text = [self.souDic objectForKey:@"name_en"];
    label4.textColor = [UIColor whiteColor];
    label4.numberOfLines = 0;
    [images addSubview:label4];
    [label4 release];
}

- (void)setView
{
    UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.bounds];
    [webView.scrollView setContentInset:UIEdgeInsetsMake(0, 0, 0, 0)];
     [webView loadHTMLString:[self.souDic objectForKey:@"tips_html"] baseURL:nil];
    [self.view addSubview:webView];
}

- (void)headlerData
{
    NSString *url = [NSString stringWithFormat:@"http://chanyouji.com/api/attractions/%@.json", self.str];
    [AFNetworkHandler GetWithAFNByURL:url completion:^(id result) {
       
        self.souDic = result;
        [self setScrollView];
        
        
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
